﻿<!doctype html>
<html>
<!-- InstanceBegin template="/Templates/template1.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>获奖名单</title>
<!-- InstanceEndEditable -->
<script type="text/javascript" src="../js/common.js"></script>
<script type="text/javascript" src="../js/checkLogin.js"></script> 
<link href="../css/Pager.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../js/jquery.pager.js"></script>
<script type="text/javascript" src="../js/gbRst.js"></script>
<script type="text/javascript" src="../js/doubleDate2.0.js"></script>
	<script type="text/javascript" src="../js/utils.js"></script>
	<script type="text/javascript" src="../js/find.js"></script>
<link href="../css/validator3.css" type="text/css" rel="stylesheet" />
	<link href="../css/style.css" type="text/css" rel="stylesheet" />
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<script type="text/javascript">
var pagecount = 0;
var pageIndex=1;
var count=0;
var winnerId = 0;

$(function(){
	findSweepstakesList()
})
function findSweepstakesList(){
	$.ajax({
		url:'../sweepstakes/find/sweepstakesList/'+pageIndex+'/10',
		datatype:'json',
		data:{'prizeTypeId':1},
		type:'get',
		success:
			function(data){
			var rst= JSON.parse(data);
			if(IsEmpty(rst)){
				art.dialog({fixed:true, lock: true,content:"修改出錯",icon:'error',ok:true});	
				return false;
				}
				if(rst.state==0){
					if(rst.result.len>0){
						loadtable(rst)	
						 var shu = rst.result.len;
						 pagecount = Math.ceil(shu/10);
						 $("#pager").pager({ pagenumber:pageIndex, pagecount: pagecount, buttonClickCallback: PageClick });

						}
				}else if(rst.state==1){
					art.dialog({fixed:true, lock: true,content:rst.msg,icon:'error',ok:true});	
				}else{
					checkStateShowErrorMsgAndDealResult(data);
				}	
			
			
		}
	})
}

PageClick = function(pageclickednumber) {
	pageIndex=pageclickednumber;
	findSweepstakesList();
}
function loadtable(rst){
	var params = new Array("swptaksName", "swptaksContent","swptaksBeginDate","staName","status","swptaksID","prizeTypeId");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
	var phArray = new Array();
	var count=0;
	if (params != null) {
		$(params).each(function(pIndex, pData) {
			$.each(rst.result.head, function(hIndex, hData) {
				if (pData == hData) {
					phArray[count++] = hIndex;
				}
			});
		});
	}
	
			$("#rewardList").empty();
		for ( var i = 0; i < rst.result.data.length; i++) {
			 var htm="<li>";
			var d=rst.result.data[i]
	
			for ( var j = 0; j < phArray.length; j++) {
				if(j==0){
					htm+="<strong>"+d[phArray[j]]+"</strong>"
				}else
				if(j==1){
					htm+="<p>"+d[phArray[j]]+"</p>";
				}else if(j==2){
					
				htm+= "<b>"+ d[phArray[j]] +"</b>"
				}else if(j==3){
					if(d[phArray[4]]==0||d[phArray[4]]==1){
						htm+="<span>进行中</span>"	
					}else if(d[phArray[4]]==2){
						htm+="<span>已结束</span>"
					}
				}else if(j==4){
				htm+="<i><input class=\"common_btn\" type=\"button\" value=\"查询获奖名单\" onclick=\"InitTable("+d[phArray[5]]+")\"></i>"
				}
			}
			htm+="</li>";
			$("#rewardList").append(htm)
		}

}

function InitTable(id) {
	
	winnerId = id
	getWinner(1)	
}

function getWinner(page){
	var name = $("#name").val()
	var mp = $("#mp").val()
	var rst = _findInfo("../winner/find/winnerList/" +(page-1)+"/10", {"swptaksId":winnerId,"name":name,"mp":mp})
	if(IsNotEmpty(rst)&&rst.state==0){
		var params = new Array("CusName", "Mp","PlName","Pname","CreateTime","staName");// "PayCash", "PayPos", "PayDepstAmt", "PayCheck", "PayPersonCard", "PayIntAmtMny", "StaName", "PaidName"
		$("#info tbody").empty()
		
		for(var i=0;i<rst.result.data.length;i++){
			var htm="<tr>"
				htm+="<td>"+getHeadIndexValue(i, rst, "CusName")+"</td>"
			    htm+="<td>"+getHeadIndexValue(i, rst, "Mp")+"</td>"
/* 				htm+="<td>"+getHeadIndexValue(i, rst, "PlName")+"</td>"
 */				htm+="<td>"+ getHtmlString(getHeadIndexValue(i, rst, "Pname"))+"</td>"
				htm+="<td>"+getHeadIndexValue(i, rst, "CreateTime")+"</td>"
				htm+="<td>"+getHeadIndexValue(i, rst, "staName")+"</td>"
				var state=getHeadIndexValue(i, rst, "status");
				if(state==0){
					htm+="<td id='lj_"+getHeadIndexValue(i,rst,"id")+"'><input class=\"common_btn\" type=\"button\" value=\"领奖\" onclick=\"tolj("+getHeadIndexValue(i,rst,"id")+")\"></td>"
				}else{
					htm+="<td></td>"
				}
				htm+="</tr>"
				$("#info tbody").append(htm)
		}
		
		
		
		_loadPage("manPager", page, 10, rst, getWinner, null)
			$("#sup2").html("共"+rst.result.len+"条");
		addMargin($("#windowPop"))
		$("#yinying1,#windowPop").show();	
		}
}


function  downResourse(){
	var params = {"swptaksId":winnerId}
	window.location.href="../winner/export/csv?"+$.param(params);

	}
	
function tolj(id){
	var dt = _editInfo("../winner/edit/editStatus", {"id":id})
	if(IsNotEmpty(dt)&&dt.state==0){
		$("#lj_"+id).empty();
		$("#lj_"+id).prev("td").html("已领奖");
	}
}	

</script>

</head>

<body>
<!-- InstanceBeginEditable name="EditRegion3" -->
<script type="text/javascript">
$(function(){
	Hover($("#rewardList"));
	$("#closeThe,#esc,#safe").click(function(){
		$("#windowPop,#yinying1").hide();
	})
	$("#rewardList i").children(":button").click(function(){
		$("#yinying1,#windowPop").show();
		//ScrollTop("div1");
	})
	addMargin($("#windowPop"));
})
</script>
<div id="windowPop" class="hideDiv" style="width: 900px;">
  <div class="closeTop"><span id="closeThe"><img src="../images/close.png"></span></div>
  <div class="boxcontent box_blue">
    <div class="boxcontent box_blue">
    <div class="box_activities">
      <div class="title"><span>中奖名单：</span><i id="partNum2"></i></div>
      <div class="Detail" id="div1" style="height: auto;">
<span>姓名：</span>
<input id="name" type="text">
<span>电话：</span>
<input id="mp" type="text">
<input onclick="getWinner(1)" type="button" class="common_btn" value="查找">
      	<table id="info" width="100%" class="member_list" cellpadding="0" cellspacing="1" border="0" id="activityrptList">
    	<caption><strong>中奖列表       <span id="sup2">共0条</span> </strong><input onclick="downResourse()" type="button" class="common_btn" value="导出数据"></caption>
    	<thead>
    	<tr>
    		<th>姓名</th>
    		<th>电话</th>
    		<!-- <th>奖项</th> -->
        	<th>奖品</th>
        	<th>中奖时间</th>
        	<th>状态</th>
        	<th>操作</th>
        </tr>
        </thead>
        <tbody>
        	
        </tbody>
    </table>
    <div id="manPager" class="shopPager"></div>
      </div>
    </div>
   
  </div>  
  </div>
</div>
<div id="yinying1"></div>
<div class="container" id="container">
  <div class="container_R fr">
    <div class="place">获奖名单</div>
    <div class="rewardTitle"><b class="name">活动名称</b><b class="det">活动简介</b><b class="date">开奖日期</b><b class="state">状态</b><b class="set">操作</b></div>
    <ul class="rewardList" id="rewardList">
      
    </ul>
    <div id="pager"></div>
  </div>
  <div class="fc"></div>
</div>
<!-- InstanceEndEditable --> 
<script type="text/javascript" src="../js/header.js"></script> 
<script type="text/javascript" src="../js/left.js"></script> 
<script type="text/javascript" src="../js/footer.js"></script> 
<script type="text/javascript">
showTab(3,3);
</script>
</body>
<!-- InstanceEnd -->
</html>
